public class Text3 {
    //57.和为S的两个数字
    public int[] twoSum(int[] nums, int target) {
        int left = 0,right = nums.length - 1;
        while(left < right){
            if (nums[left]+nums[right]<target){
                left++;
            } else if (nums[left]+nums[right]>target){
                right--;
            } else {
                break;
            }
        }
        int[] ret = {nums[left],nums[right]};
        return ret;
    }
}
